#!/bin/sh
#
# Launch n stations, data sinks and data sources with associated parameters.
#
# Parameter:	1 - # of stations
#		2 - interface
#		3 - team
#		4 - run time
#		5 - multicast adress
#		6 - multicast port
#		7 - mode
#
# (by H. Schulz 2011)
#


NumStations=$1
Interface=$2
Team=$3
Runtime=$4
MCastAddress=$5
MulticastPort=$6
Mode=$7

# Base ports for data sink and source
DataSinkBasePort=17000
DataSourceBasePort=16000

if [ $# -gt 6 ] ; then
	count=1
	while [ $count -le $NumStations ] ; do
		# calculate ports for data sink and source
		#Message="team1: "
		DataSinkPort=`expr $DataSinkBasePort + $count`
		DatatSourcePort=`expr $DataSourceBasePort + $count`

		# launch data sink, data source and station
	 	./starter $Interface $DataSinkPort $DatatSourcePort $Team $count $Runtime $MCastAddress $MulticastPort $Mode &

		count=`expr $count + 1`
	done
else
	echo "Usage: $0 <# of stations> <net inteface> <team> <run-time> <multicast Addr> <multicast Port> <syncMode |0 = normal | 1= sync>"
fi

exit 1